<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>签到</title>
    <style>
    
	html,
	body {
        width: 100%;
        height: 100%;
		margin: 0;
		padding: 0;
		border: none;
        /* padding-top: 2.26rem; */
		background: -webkit-linear-gradient(#484336, #252626);
		background: -o-linear-gradient(#484336, #252626);
		background: -moz-linear-gradient(#484336, #252626);
		background: linear-gradient(#484336, #252626);
		color: #fff98d;
    box-sizing: border-box;
	}
		footer {
		width: 10rem;
		height: 1.33rem;
		left: 50%;
		transform: translate(-50%);
		background-color: #131314;
		position: fixed;
		bottom: 0;
		z-index: 1111;
		display: flex;
		justify-content: space-around;
		box-sizing: border-box;
		padding: 5px 0;
	}
	footer a {
		color: #fff98d;
		display: block;
		text-align: center;
		text-decoration: none;
		-webkit-tap-highlight-color: rgba(255, 255, 255, 0);
		-webkit-user-select: none;
		-moz-user-focus: none;
		-moz-user-select: none;
		font-size: 0.246rem;
	}
	footer a p{
		color: #fff98d;
		margin: 0 !important;
	}
	footer a img{
		width:0.72rem;
		height: 0.653rem;
	}
    main{
        text-align: center;
    }
    .gold img{
      width: 2.42rem;
	  margin-top: 2.26rem;
    } 
    p{
        margin: 0;
    }
    .p1{
        color: #fff98d;
        font-size: 0.853rem;
        margin: 0.3rem 0;
    }
    .p2{
        font-size: 0.4rem;
        width: 3.57rem;
        height: 0.8rem;
        margin: 0.4rem auto;
        border: 1px solid #fff98d;
        line-height: 0.8rem;
        text-align: center;
        border-radius: 0.8rem;
        background-color: #1f1f1f;

    }
    .p3{
       color: #8d8b71;
       font-size: 0.5rem;
     margin-bottom: 0.7rem;
    }
    .btn{
        font-size: 0.346rem;
        width: 7.46rem;
        height: 1.2rem;
        background: -webkit-linear-gradient(left, #fffb91, #ffb128); 
        background: -o-linear-gradient(right, #fffb91, #ffb128);
        background: -moz-linear-gradient(right, #fffb91, #ffb128); 
        background: linear-gradient(to right, #fffb91, #ffb128); 
        border: none;
        outline: none;
        border-radius: 8px;
		margin-top: 0.6rem;
	}
	header{
          width: 100%;
          height: 1.2rem;
          background-color: #2c2d25;
          color: #d6d178;
          font-size: 0.346rem;
          text-align: center;
          line-height: 1.2rem;
          position: fixed;
          z-index: 111;
          bottom: 0;
      }
      header nav a{
          color: #d6d178;
          font-size: 0.4rem;
          text-decoration: none;
          /* position: absolute; */
          /* left: 0.3rem; */
          -webkit-tap-highlight-color: rgba(255, 255, 255, 0);
            -webkit-user-select: none;
            -moz-user-focus: none;
            -moz-user-select: none;
	  }
     .success{
		 width: 4rem;
		 height: 4rem;
		 background-color: black;
		 opacity: 0.9;
		 margin: 0 auto;
		 text-align: center;
		 position: absolute;
		 top: 30%;
		 left: 50%;
		 margin-left: -2rem;
		 display: none;
		 z-index: 1111;
	 }
	 .success p{
		 font-size: 0.5rem;
		 margin-top: 0.4rem;
	 }
	 .right{
		 width: 2rem;
		 height: 1.44rem;
		 margin-top: 0.6rem;
	 }
    </style>
</head>
<body>
    <main>
        <div class="gold"><img src="__PUBLIC__/Home/img/gold_icon.png" alt=""></div>
        <p class="p1">签到领福利</p>
        <!-- <p class="p2">您已连续签到<span class="day">3</span>天</p> -->
        <!-- <p class="p3">今日还未签到</p> -->
		<button class="btn"></button>
		<span id="name" style="display:none;">{$userinfo.nickname}</span>
		<span id="uid" style="display:none;">{$userinfo.id}</span>
	</main>
	<div class="success">
		<img src="__PUBLIC__/Home/img/right.png" alt="" class="right">
		<p>签到成功</p>
	</div>
	
	<header>
			<nav>
				<a href="javascript:history.back()">返回</a>
				  <!-- <span>优惠活动</span> -->
			</nav>
		   </header>
    <script src="__PUBLIC__/Admin/js/jquery.min.js?v=2.1.4"></script>
	<!-- <script src="__PUBLIC__/Common/js/ajaxForm.js"></script>
	<script src="__PUBLIC__/layer/layer.js"></script> -->
	<script>
		
		// console.log(day)
	 $(function(){
		var user_name = $('#name').html()
			  var user_id = $('#uid').html()
			  console.log(user_name)
			  console.log(user_id)
			var day = new Date()
			 date = day.getFullYear() +''+ ((day.getMonth()+1) < 10?'0' + (day.getMonth()+1):(day.getMonth()+1))  + '' + (day.getDate() < 10?'0' + day.getDate():day.getDate());
			 console.log(date)
       $.ajax({
		url:"{:U('Home/Index/signed')}",
				type: "post",
                cache:false,
                data: {day:date,user_name:user_name,user_id:user_id},
                dataType: "json",
                contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                success: function(req) {
                    console.log(req.msg)
					if(req.msg == '您已签过'){
						$('.btn').html(req.msg)
					    $('.btn').attr('disabled',"true")
					}
					$('.btn').html(req.msg)
                },
                //请求出错处理。注意：有差错时才执行程序体，才会出现alert弹框
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert('a')
                },
	   })

		$('.btn').click(function(){
			  var user_name = $('#name').html()
			  var user_id = $('#uid').html()
			  console.log(user_name)
			  console.log(user_id)
			var day = new Date()
			 date = day.getFullYear() +''+ ((day.getMonth()+1) < 10?'0' + (day.getMonth()+1):(day.getMonth()+1)) + '' + (day.getDate() < 10?'0' + day.getDate():day.getDate());
			 console.log(date)
			  $.ajax({
				  url:"{:U('Home/Index/dayCard')}",
				  type: "post",
                cache:false,
                data: {day:date,user_name:user_name,user_id:user_id},
                dataType: "json",
                contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                success: function(req) {
                    console.log(req.msg)
					$('.success').css('display','block')
					setTimeout(function(){$('.success').css('display','none') }, 3000);
					$('.btn').html(req.msg)
					$('.btn').attr('disabled',"true")
				
                },
                //请求出错处理。注意：有差错时才执行程序体，才会出现alert弹框
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                
                },
               
			  })
		  })
	 })
	</script>
	<script>
		;
		(function (win, lib) {
			var doc = win.document;
			var docEl = doc.documentElement;
			var metaEl = doc.querySelector('meta[name="viewport"]');
			var flexibleEl = doc.querySelector('meta[name="flexible"]');
			var dpr = 0;
			var scale = 0;
			var tid;
			var flexible = lib.flexible || (lib.flexible = {});
	
			if (metaEl) {
				// console.warn('将根据已有的meta标签来设置缩放比例');
				var match = metaEl.getAttribute('content').match(/initial\-scale=([\d\.]+)/);
				if (match) {
					scale = parseFloat(match[1]);
					dpr = parseInt(1 / scale);
				}
			} else if (flexibleEl) {
				var content = flexibleEl.getAttribute('content');
				if (content) {
					var initialDpr = content.match(/initial\-dpr=([\d\.]+)/);
					var maximumDpr = content.match(/maximum\-dpr=([\d\.]+)/);
					if (initialDpr) {
						dpr = parseFloat(initialDpr[1]);
						scale = parseFloat((1 / dpr).toFixed(2));
					}
					if (maximumDpr) {
						dpr = parseFloat(maximumDpr[1]);
						scale = parseFloat((1 / dpr).toFixed(2));
					}
				}
			}
			if (!dpr && !scale) {
				var isAndroid = win.navigator.appVersion.match(/android/gi);
				var isIPhone = win.navigator.appVersion.match(/iphone/gi);
				var devicePixelRatio = win.devicePixelRatio;
				if (isIPhone) {
					// iOS下，对于2和3的屏，用2倍的方案，其余的用1倍方案
					if (devicePixelRatio >= 3 && (!dpr || dpr >= 3)) {
						dpr = 3;
					} else if (devicePixelRatio >= 2 && (!dpr || dpr >= 2)) {
						dpr = 2;
					} else {
						dpr = 1;
					}
				} else {
					// 其他设备下，仍旧使用1倍的方案
					dpr = 1;
				}
				scale = 1 / dpr;
			}
			docEl.setAttribute('data-dpr', dpr);
			if (!metaEl) {
				metaEl = doc.createElement('meta');
				metaEl.setAttribute('name', 'viewport');
				metaEl.setAttribute('content', 'initial-scale=' + scale + ', maximum-scale=' + scale +
					', minimum-scale=' + scale + ', user-scalable=no');
				if (docEl.firstElementChild) {
					docEl.firstElementChild.appendChild(metaEl);
				} else {
					var wrap = doc.createElement('div');
					wrap.appendChild(metaEl);
					doc.write(wrap.innerHTML);
				}
			}
	
			function refreshRem() {
				var width = docEl.getBoundingClientRect().width;
				if (width / dpr > 750) {
					width = 750 * dpr;
				}
				var rem = width / 10;
				docEl.style.fontSize = rem + 'px';
				flexible.rem = win.rem = rem;
			}
			win.addEventListener('resize', function () {
				clearTimeout(tid);
				tid = setTimeout(refreshRem, 100);
			}, false);
			win.addEventListener('pageshow', function (e) {
				if (e.persisted) {
					clearTimeout(tid);
					tid = setTimeout(refreshRem, 100);
				}
			}, false);
			if (doc.readyState === 'complete') {
				doc.body.style.fontSize = 12 * dpr + 'px';
			} else {
				doc.addEventListener('DOMContentLoaded', function (e) {
					doc.body.style.fontSize = 12 * dpr + 'px';
				}, false);
			}
	
			refreshRem();
			flexible.dpr = win.dpr = dpr;
			flexible.refreshRem = refreshRem;
			flexible.rem2px = function (d) {
				var val = parseFloat(d) * this.rem;
				if (typeof d === 'string' && d.match(/rem$/)) {
					val += 'px';
				}
				return val;
			}
			flexible.px2rem = function (d) {
				var val = parseFloat(d) / this.rem;
				if (typeof d === 'string' && d.match(/px$/)) {
					val += 'rem';
				}
				return val;
			}
		})(window, window['lib'] || (window['lib'] = {}));
	</script>
	<!-- <script type="text/javascript">
		$(function () {
			$('#LoginForm').ajaxForm({
				beforeSubmit: checkForm,
				success: complete,
				dataType: 'json'
			});

			function checkForm() {
				if ($("#money").val() > parseInt($('.yong').text())) {
					layer.alert('佣金不足', {
						icon: 5
					}, function (index) {
						layer.close(index);
						$('#money').focus();
					});
					return false;
				}
			}

			function complete(data) {
				if (data.status == 1) {
					$('.btn').attr('disabled', 'disabled');
					layer.msg(data.info, function (index) {
						layer.close(index);
						window.location.href = data.url;
					});
				} else {
					layer.msg(data.info);
					$('#password').val('').focus();
					return false;
				}
			}
		});
	</script> -->
</body>
</html>